package com.study.demo.controller;

import com.study.demo.vo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author yinyin
 * @create 2024/12/03 下午 4:24
 */
@Api(tags = "测试")
@Controller
public class HelloController {
    @ResponseBody
    @GetMapping("hello")
    public String helloController(){
        return "hello";
    }
    @ApiOperation("根据id获取数据")
    @GetMapping("user/{id}")
    public String testPathVarible(@PathVariable int id){
        System.out.println("id的值为"+id);
        return "success";
    }

    @GetMapping("user1")
    public String testParam(@RequestParam int id){
        System.out.println("id的值为"+id);
        return "success";
    }
    @ApiOperation("post传输数据")
    @PostMapping("form")
    public String testPost(@RequestBody User user){
        System.out.println(user.getUsername());
        System.out.println(user.getPassword());
        return "success";
    }

    @GetMapping("index")
    public String index(){
        return "index";
    }



}
